import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:niuren_demo/configs/App_style_config.dart';
import 'package:niuren_demo/model/ApiAccountItem_model.dart';
import 'package:niuren_demo/view/dynamic_page/ApiAccountItem.dart';
import 'package:niuren_demo/view/dynamic_page/ApiAccountTitle.dart';

class ApiAccountPage extends StatefulWidget {
  @override
  _ApiAccountPageState createState() => _ApiAccountPageState();
}

class _ApiAccountPageState extends State<ApiAccountPage> {
  List ApiAccountDataSoure=[
    {
      "imageurl":
      "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fb-ssl.duitang.com%2Fuploads%2Fitem%2F201808%2F15%2F20180815112431_keyzi.thumb.700_0.jpeg&refer=http%3A%2F%2Fb-ssl.duitang.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1617851642&t=7b6a7c66ce19ae61adcdf25c8c3b8856",
      "title": "OKEX",
      "tip1": "币本位永续合约",
      "tip2": "BTC/USD",
      "start": "12,345.00",
      "yesterday": "12,345.00",
      "today": "12,345.00",
      "duocang": 70,
      "kongcang": 70,
      "cc_price1": "12,345.00",
      "cc_price2": "12,345.00",
    },
    {
      "imageurl":
      "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fb-ssl.duitang.com%2Fuploads%2Fitem%2F201808%2F15%2F20180815112431_keyzi.thumb.700_0.jpeg&refer=http%3A%2F%2Fb-ssl.duitang.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1617851642&t=7b6a7c66ce19ae61adcdf25c8c3b8856",
      "title": "OKEX",
      "tip1": "币本位永续合约",
      "tip2": "BTC/USD",
      "start": "12,345.00",
      "yesterday": "12,345.00",
      "today": "12,345.00",
      "duocang": 70,
      "kongcang": 70,
      "cc_price1": "12,345.00",
      "cc_price2": "12,345.00",
    },
  ];
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: ListView.builder(
        shrinkWrap: true, //为true可以解决子控件必须设置高度的问题
        physics: NeverScrollableScrollPhysics(),
        itemBuilder: (context, index) {
          if(index == 0){
            return ApiAccountTitle();
          }
          return ApiAccountItem(dataModel: ApiAccountItem_Model.fromJson(ApiAccountDataSoure[index-1]));
        },
        itemCount: ApiAccountDataSoure.length + 1,
      ),
    );
  }
}
